//h5获取经纬度
function getLocation1(){
    console.log(navigator.geolocation);
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        alert('Geolocation is not supported by this browser.');
    }
    function showPosition(position) {
        latitudeH5 = position.coords.latitude;
        longitudeH5 = position.coords.longitude;
        var htmlH5 = `<div>H5(latitudeH5):${latitudeH5};H5(longitudeH5):${longitudeH5}</div>`;
        $(".geoH5").append(htmlH5);
        //console.log('Latitude: ' + latitude + ', Longitude: ' + longitude);
        //alert('Latitude: ' + latitude + ', Longitude: ' + longitude);
    }
}

//百度地图获取经纬度
function getLocation2() {
    // 创建百度地理位置实例，代替 navigator.geolocation
    let geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(e) {
        if(this.getStatus() == BMAP_STATUS_SUCCESS){
            // 百度 geolocation 的经纬度属性不同，此处是 point.lat 而不是 coords.latitude
            //x.innerHTML = '纬度：' + e.point.lat + '<br/>经度：' + e.point.lng;
            latitudeBd = e.point.lat;
            longitudeBd = e.point.lng;
            var htmlBd = `<div>Bd(latitudeBd):${latitudeBd};Bd(longitudeBd):${longitudeBd}</div>`;
            $(".geoBd").append(htmlBd);
        } else {
            //x.innerHTML = 'failed' + this.getStatus();
            console.log(this.getStatus());
        }
    });
}